package com.koron.ticket.line.workChange.ticketchange.controller;


import com.github.pagehelper.PageHelper;
import com.koron.bean.base.Response;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.ticket.line.workChange.ticketchange.bean.TicketChange;
import com.koron.ticket.line.workChange.ticketchange.bean.TicketChangeQuery;
import com.koron.ticket.line.workChange.ticketchange.service.TicketChangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * (TicketChange)表控制层
 *
 * @author 
 * @since 2021-10-26 11:56:35
 */
@Api(tags = "线路工作票变更接口")
@RestController("lineTicketChangeController")
@RequestMapping("lineTicketChange")
public class TicketChangeController {
    
    @Autowired
    private TicketChangeService lineTicketChangeService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }
    
    /**
     * 新增单条数据
     *
     * @param 
     * @return Response
     * @see Response
     * @version 1.0
     */
    @PostMapping("insert")
    @ApiOperation(value = "新增单条数据")
    public Response insert(@RequestBody TicketChange ticketChange) {
        return ADOConnection.runTask(getCurrDs(), lineTicketChangeService, "insert", Response.class, ticketChange);
    }
    
    /**
     * 删除单条数据
     *
     * @param id 主键
     * @return Response对象
     * @see Response
     * @version 1.0
     */
    @DeleteMapping("deleteById")
    @ApiOperation(value = "根据id删除单条数据")
    public Response deleteById(@RequestParam("id") String id) {
        return ADOConnection.runTask(getCurrDs(), lineTicketChangeService, "deleteById", Response.class, id);
    }
    
    /**
     * 修改数据
     *
     * @param ticketChange
     * @return Response
     * @see Response
     * @version 1.0
     */
    @PutMapping("update")
    @ApiOperation(value = "修改单条配置详情")
    public Response update(@RequestBody TicketChange ticketChange) {
        return ADOConnection.runTask(getCurrDs(), lineTicketChangeService, "update", Response.class, ticketChange);
    }

    /**
     * 通过id查询单条数据
     *
     * @param id 主键
     * @return Response
     * @see Response
     * @version 1.0
     */
    @ApiOperation(value = "根据id查询")
    @GetMapping("getById")
    public Response getById(@RequestParam("id") String id) {
        return ADOConnection.runTask(getCurrDs(), lineTicketChangeService, "getById", Response.class, id);
    }

    @ApiOperation(value = "分页查询数据")
    @PostMapping("getListAndPaging")
    public Response getListAndPaging(@RequestBody TicketChangeQuery ticketChangeQuery) {
        PageHelper.startPage(ticketChangeQuery.getPage(), ticketChangeQuery.getPageSize(), ticketChangeQuery.getOrderBy());
        return ADOConnection.runTask(getCurrDs(), lineTicketChangeService, "getListAndPaging", Response.class, ticketChangeQuery);
    }
//
//    @ApiOperation(value = "根据workTicketId查询对应的变更项")
//    @GetMapping("getByWorkTicketId")
//    public Response getByWorkTicketId(@RequestParam("workTicketId") String workTicketId) {
//        return ADOConnection.runTask(getCurrDs(), lineTicketChangeService, "getByWorkTicketId", Response.class, workTicketId);
//    }


}
